import React from 'react';
import { Editor } from '@tiptap/react';

interface UndoRedoButtonProps {
  editor: Editor;
  type: 'undo' | 'redo';
  icon: string;
  title?: string;
}

const UndoRedoButton: React.FC<UndoRedoButtonProps> = ({
  editor,
  type,
  icon,
  title = ''
}) => {
  const handleClick = () => {
    if (type === 'undo') {
      editor.chain().focus().undo().run();
    } else {
      editor.chain().focus().redo().run();
    }
  };

  return (
    <button
      onClick={handleClick}
      className="toolbar-button"
      title={title}
    >
      <i className="icon">{icon}</i>
    </button>
  );
};

export default UndoRedoButton;